<?php

$handle = opendir("./");
$str = '';
while (($file = readdir($handle)) !== false) {
    if(is_file($file) && strpos($file,'icon') !== false){
        $arr = explode('.',$file);
        $filename = array_shift($arr);
        $name = str_replace('icon_','',$filename);
        $str = ".key-item.$name{";
        $str .= "background-image: url(\"../image/$filename.png\");";
        $str .= "}";
        echo $str;
    }
}